#include "fxcc/core/BaseImporter.h"
#include "fxcc/core/graph/common/ModelMetaCacheFile.h"

template<>
void fxcc::yml::Serializer::Encode<ModelMetaCache>(YAML::Node& node, const ModelMetaCache& inst)
{
	auto func = [=](const MetaMapIndex& index) {
		return fs::exists(index.m_NativeFile); };

	SetArrayVariable<MetaMapIndex>(node, "m_MeshMetaIndexes", inst.m_MeshMetaIndexes,func);
	SetArrayVariable<MetaMapIndex>(node, "m_SkinnedMetaIndexes", inst.m_SkinnedMetaIndexes, func);
	SetArrayVariable<MetaMapIndex>(node, "m_BoneMetaIndexes", inst.m_BoneMetaIndexes, func);
	SetArrayVariable<MetaMapIndex>(node, "m_MaterialMetaIndexes", inst.m_MaterialMetaIndexes, func);
	SetArrayVariable<MetaMapIndex>(node, "m_RealMaterialMetaIndexes", inst.m_RealMaterialMetaIndexes, func);
	SetArrayVariable<MetaMapIndex>(node, "m_AnimationMetaIndexes", inst.m_AnimationMetaIndexes, func);
}


template<>
bool fxcc::yml::Serializer::Decode<ModelMetaCache>(const YAML::Node& node, ModelMetaCache& inst)
{
	GetArrayVariable<MetaMapIndex>(node, "m_MeshMetaIndexes", inst.m_MeshMetaIndexes);
	GetArrayVariable<MetaMapIndex>(node, "m_SkinnedMetaIndexes", inst.m_SkinnedMetaIndexes);
	GetArrayVariable<MetaMapIndex>(node, "m_BoneMetaIndexes", inst.m_BoneMetaIndexes);
	GetArrayVariable<MetaMapIndex>(node, "m_MaterialMetaIndexes", inst.m_MaterialMetaIndexes);
	GetArrayVariable<MetaMapIndex>(node, "m_RealMaterialMetaIndexes", inst.m_RealMaterialMetaIndexes);
	GetArrayVariable<MetaMapIndex>(node, "m_AnimationMetaIndexes", inst.m_AnimationMetaIndexes);
	return true;
}